module.exports = (req, res, next) => {
  // 成功响应
  res.sendRes = ({
    code = 200,
    data = null,
    success = true,
    message = "成功",
  }) => {
    res.type("application/json; charset=utf-8");
    res.status(code).json({
      code,
      data,
      success,
      message,
    });
    return;
  };

  // 错误响应
  res.sendErr = ({
    code = 200,
    data = null,
    success = false,
    message = "未知错误",
  }) => {
    res.type("application/json; charset=utf-8");
    res.status(code).json({
      code,
      data,
      success,
      message,
    });
  };
  next();
};
